package org.xu.upms.server.common;

import java.util.Timer;
import java.util.TimerTask;



public abstract class TokenManager {

	//过期时间
	protected  int  tokenTimeout = 1800;//30分钟
	//是否为后台线程
	private final  Timer timer = new Timer(true);
	
	public TokenManager(){
		timer.schedule(new TimerTask(){

			@Override
			public void run() {
				verifyExpired();  
			}
			
		}, 60*1000, 60*1000);
	}
	public void setTokenTimeout(int tokenTimeout) {
		this.tokenTimeout = tokenTimeout;
	}
	public abstract void verifyExpired();
	
	public abstract void addToken(String token,LoginUser loginUser);
	
	public abstract void removeToken(String token);
	
	public abstract LoginUser validate(String token);
}
